<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;

class UserController extends Controller {


    //列表
    public function index(Request $request){
        $params = [
            'kwd'    => (string)$request->get('kwd',''),
            'mobile' => (string)$request->get('mobile',''),
            'level' => (int)$request->get('level',0),
            'uid' => (int)$request->get('uid',0),
        ];
        $lists = User::getList($params);
        return $this->writeJson(0,$lists);
    }


    public function agent(Request $request){
        $id = (int)$request->get('id',0);
        //查找一级代理
        $ones = User::select(['id','username','agent_one','agent_two'])->where('agent_one',$id)->get();
        //查找二级代理
        $twos = User::select(['id','username','agent_one','agent_two'])->where('agent_two',$id)->get();
        return $this->writeJson(0,['ones' => $ones,'twos' => $twos]);
    }

}
